package com.wpen.unit.web.controller.job;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.wpen.unit.service.job.AgentRegistryService;
import com.wpen.unit.web.dto.AgentRegistryRequest;
import com.wpen.unit.web.dto.AgentRegistryResponse;
import com.wpen.unit.web.dto.job.AgentRegistryListRequest;
import com.wpen.unit.web.dto.job.AgentRegistryListResponse;
import com.wpen.unit.web.dto.job.AgentRegistryModRequest;
import com.wpen.unit.web.dto.job.AgentRegistryModResponse;
import com.wpen.unit.web.dto.job.AgentRegistryOfflineRequest;
import com.wpen.unit.web.dto.job.AgentRegistryOfflineResponse;
import com.wpen.unit.web.dto.job.AgentRegistryOnlineRequest;
import com.wpen.unit.web.dto.job.AgentRegistryOnlineResponse;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

/**
 * 执行器注册维护
 * 
 * @author pg
 *
 */
@Tag(name = "执行器模块服务接口")
@RestController
@RequestMapping("/api")
public class AgentController {
	@Autowired
	private AgentRegistryService agentRegistryService;

	@Operation(summary = "执行器注册-列表查询")
	@PostMapping(value = "/agent/list", produces = MediaType.APPLICATION_JSON_VALUE)
	public AgentRegistryListResponse queryListAgentRegistry(
			@RequestBody @Valid AgentRegistryListRequest agentRegistryListRequest) {
		return agentRegistryService.queryListAgentRegistry(agentRegistryListRequest);
	}

	@Operation(summary = "执行器注册-新增")
	@PostMapping(value = "/public/agent/registry", produces = MediaType.APPLICATION_JSON_VALUE)
	public AgentRegistryResponse addAgentRegistry(@RequestBody @Valid AgentRegistryRequest agentRegistryAddRequest) {
		return agentRegistryService.addAgentRegistry(agentRegistryAddRequest);
	}

	@Operation(summary = "执行器注册-修改")
	@PostMapping(value = "/agent/mod", produces = MediaType.APPLICATION_JSON_VALUE)
	public AgentRegistryModResponse modAgentRegistry(
			@RequestBody @Valid AgentRegistryModRequest agentRegistryModRequest) {
		return agentRegistryService.modAgentRegistry(agentRegistryModRequest);
	}
	
	@Operation(summary = "执行器注册-下线")
	@PostMapping(value = "/agent/offline", produces = MediaType.APPLICATION_JSON_VALUE)
	public AgentRegistryOfflineResponse offlineAgentRegistry(
			@RequestBody @Valid AgentRegistryOfflineRequest agentRegistryOfflineRequest) {
		return agentRegistryService.offlineAgentRegistry(agentRegistryOfflineRequest);
	}
	
	@Operation(summary = "执行器注册-上线")
	@PostMapping(value = "/agent/online", produces = MediaType.APPLICATION_JSON_VALUE)
	public AgentRegistryOnlineResponse onlineAgentRegistry(
			@RequestBody @Valid AgentRegistryOnlineRequest agentRegistryOnlineRequest) {
		return agentRegistryService.onlineAgentRegistry(agentRegistryOnlineRequest);
	}

}
